#pragma once
#include "InternalsPlugin.hpp"
#include "Sprite.hpp"
#include "DriverInfo.hpp"
#include "TimingInfo.hpp"
#include "TypeDefs.hpp"



class DriverTiming
{
public:
	DriverTiming(const char *pRootPath, const char *pIniUIFilename, const char *pIniDriverMappingFilename, const char *pIniVehiculeClassMappingFilename);
	virtual ~DriverTiming(void);

	void init(const ScreenInfoV01 &info, float ratio, float ratioWidth, float ratioHeight, Sprite spriteList[]);
	void updateData(const ScoringInfoV01 &info, const VehicleScoringInfoV01 &vinfo, DriverInfo & di, TimingInfo & timingAllCategory, TimingInfo & timingInCategory);
	void render(int profileIndex, const ScreenInfoV01 &info, const LPD3DXFONT *fontList, const D3DCOLOR *colorList, Sprite spriteList[]); 

	std::string getTimeAsString(double seconds, bool forceAllFields, bool padHighest, bool showMillis, bool showFullMillis);
	
	bool initialized;
	const char *rootPath;
	char iniUIFilename[800];
	const char *iniDriverMappingFilename;
	const char *iniVehiculeClassMappingFilename;

	char mLastDriverName[32]; // track if we change the viewed driver (between to updateData call)

	
	int nbProfiles;
	PluginProfile profiles[10];

	RECT tmpRect;

	char tmp[1000];


	// Driver Timing (general)
	bool available;
	bool isPinned;
	int displayDurationUnpined;
	bool forceDisplay;
	double lastPilotChangeET;
	double currentET;
	bool pilotHaveChange; // avoid wrong display of S1 & S2 if change to a driver in its first second of a new turn

	ImageData bgImageData;


	////////////////////////////////////////////////////
	// S1 
	////////////////////////////////////////////////////
	// S1 Tag
    bool s1TagAvailable;
    TextData s1TagTextData;
    ImageData s1TagImageData;
	// S1 Tag (MyCat)
    bool s1TagMyCatAvailable;
    TextData s1TagMyCatTextData;
    ImageData s1TagMyCatImageData;
	bool haveBestS1InMyCat;
	
	// S1 Tag (AllCat)
    bool s1TagAllCatAvailable;
    TextData s1TagAllCatTextData;
    ImageData s1TagAllCatImageData;
	bool haveBestS1InAllCat;

	// S1 Value
    bool s1ValueAvailable;
    TextData s1ValueTextData;
    ImageData s1ValueImageData;
	char s1Value[20];
	// S1 Value (Better)
    bool s1ValueBetterAvailable;
    TextData s1ValueBetterTextData;
    ImageData s1ValueBetterImageData;
	bool haveBetterS1;
	
	// S1 Value (Worst)
    bool s1ValueWorstAvailable;
    TextData s1ValueWorstTextData;
    ImageData s1ValueWorstImageData;
	bool haveWorstS1;
	
	////////////////////////////////////////////////////
	// S2 (S2+S1)
	////////////////////////////////////////////////////
	// S2 Tag
    bool s2TagAvailable;
    TextData s2TagTextData;
    ImageData s2TagImageData;
	// S2 Tag (MyCat)
    bool s2TagMyCatAvailable;
    TextData s2TagMyCatTextData;
    ImageData s2TagMyCatImageData;
	bool haveBestS2InMyCat;
	// S2 Tag (AllCat)
    bool s2TagAllCatAvailable;
    TextData s2TagAllCatTextData;
    ImageData s2TagAllCatImageData;
	bool haveBestS2InAllCat;

	// S2 Value
    bool s2ValueAvailable;
    TextData s2ValueTextData;
    ImageData s2ValueImageData;
	char s2Value[20];
	// S2 Value (Better)
    bool s2ValueBetterAvailable;
    TextData s2ValueBetterTextData;
    ImageData s2ValueBetterImageData;
	bool haveBetterS2;
	
	// S2 Value (Worst)
    bool s2ValueWorstAvailable;
    TextData s2ValueWorstTextData;
    ImageData s2ValueWorstImageData;
	bool haveWorstS2;
	
	////////////////////////////////////////////////////
	// S3 (Laptime)
	////////////////////////////////////////////////////
	// S3 Tag 
    bool s3TagAvailable;
    TextData s3TagTextData;
    ImageData s3TagImageData;
	// S3 Tag (MyCat)
    bool s3TagMyCatAvailable;
    TextData s3TagMyCatTextData;
    ImageData s3TagMyCatImageData;
	bool haveBestS3InMyCat;
	// S3 Tag (AllCat)
    bool s3TagAllCatAvailable;
    TextData s3TagAllCatTextData;
    ImageData s3TagAllCatImageData;
	bool haveBestS3InAllCat;

	// S3 Value
    bool s3ValueAvailable;
    TextData s3ValueTextData;
    ImageData s3ValueImageData;
	char s3Value[20];
	// S3 Value (Better)
    bool s3ValueBetterAvailable;
    TextData s3ValueBetterTextData;
    ImageData s3ValueBetterImageData;
	bool haveBetterS3;
	
	// S3 Value (Worst)
    bool s3ValueWorstAvailable;
    TextData s3ValueWorstTextData;
    ImageData s3ValueWorstImageData;
	bool haveWorstS3;

	////////////////////////////////////////////////////
	// Gap
	////////////////////////////////////////////////////
	// Gap Value
    bool gapValueAvailable;
    TextData gapValueTextData;
    ImageData gapValueImageData;
	char gapValue[20];
	// Gap Value (Better)
    bool gapValueBetterAvailable;
    TextData gapValueBetterTextData;
    ImageData gapValueBetterImageData;
	bool isBetterGap;
	
	// Gap Value (Worst)
    bool gapValueWorstAvailable;
    TextData gapValueWorstTextData;
    ImageData gapValueWorstImageData;
	bool isWorstGap;

	////////////////////////////////////////////////////
	// Laptime
	////////////////////////////////////////////////////
	// Laptime Value
    bool laptimeValueAvailable;
    TextData laptimeValueTextData;
    ImageData laptimeValueImageData;
	char laptimeValue[20];
	// Laptime Value (Better)
    bool laptimeValueBetterAvailable;
    TextData laptimeValueBetterTextData;
    ImageData laptimeValueBetterImageData;
	bool isBetterLaptime;
	
	// Laptime Value (Worst)
    bool laptimeValueWorstAvailable;
    TextData laptimeValueWorstTextData;
    ImageData laptimeValueWorstImageData;
	bool isWorstLaptime;

	// Laptime Value (Best)
    bool laptimeValueBestAvailable;
    TextData laptimeValueBestTextData;
    ImageData laptimeValueBestImageData;
	bool isBestLaptime;

	////////////////////////////////////////////////////
	// Self Best
	////////////////////////////////////////////////////
	// Self Best
    bool selfBestValueAvailable;
    TextData selfBestValueTextData;
	char selfBestValue[20];

	////////////////////////////////////////////////////
	// Leader Best
	////////////////////////////////////////////////////
	// Leader Best
    bool leaderBestValueAvailable;
    TextData leaderBestValueTextData;
	char leaderBestValue[20];

};

